package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-07-04
 * Time: 13:54
 */
public class ThreadDemo15 {
    public static void main(String[] args) throws InterruptedException {
        Object o = new Object();
        System.out.println("wait之前");
        //1. 解锁
        //2. 阻塞等待
        //3. 当收到通知时，就唤醒，同时重新获取锁
        //所以wait()必须在synchronized中使用
        //o.wait();//IllegalMonitorStateException,无效锁状态异常
        synchronized (o) {//加锁对象必须和wait是同一个
            o.wait();
        }
        System.out.println("wait之后");
    }
}
